﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;

namespace RoccaStore.Web
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            routes.MapRoute(
                name: "Errors",
                url: "errors/{action}/{id}",
                defaults: new { controller = "Errors", action = "Index", id = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "AddressBook",
                url: "addressbook/{action}/{id}",
                defaults: new { controller = "AddressBook", action = "Index", id = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "Page",
                url: "page/{action}/{id}",
                defaults: new { controller = "Page", action = "Index", id = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "Account",
                url: "account/{action}/{id}",
                defaults: new { controller = "Account", action = "Index", id = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "Email",
                url: "email/{action}/{id}",
                defaults: new { controller = "Email", action = "Index", id = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "FileComplete",
                url: "complete/{slug}/{hash}",
                defaults: new { controller = "File", action = "Complete", hash = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "File",
                url: "file/{action}/{id}",
                defaults: new { controller = "File", action = "Index", id = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "Download",
                url: "download/{slug}/{hash}",
                defaults: new { controller = "File", action = "Download", slug = UrlParameter.Optional, hash = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "Complete",
                url: "complete/{slug}/{hash}/",
                defaults: new { controller = "File", action = "Complete", hash = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "Delete",
                url: "delete/{slug}/{hash}/",
                defaults: new { controller = "File", action = "Delete", hash = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "FileSlug",
                url: "{slug}/{hash}",
                defaults: new { controller = "Home", action = "Index", slug = UrlParameter.Optional, hash = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}